<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE Unsafe #-}</span><span>
</span><span id="line-2"></span><span class="hs-pragma">{-# LANGUAGE NoImplicitPrelude #-}</span><span>
</span><span id="line-3"></span><span class="hs-pragma">{-# OPTIONS_HADDOCK not-home #-}</span><span>
</span><span id="line-4"></span><span>
</span><span id="line-5"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-6"></span><span class="hs-comment">-- |</span><span>
</span><span id="line-7"></span><span class="hs-comment">-- Module      :  Foreign.ForeignPtr.Imp</span><span>
</span><span id="line-8"></span><span class="hs-comment">-- Copyright   :  (c) The University of Glasgow 2001</span><span>
</span><span id="line-9"></span><span class="hs-comment">-- License     :  BSD-style (see the file libraries/base/LICENSE)</span><span>
</span><span id="line-10"></span><span class="hs-comment">-- </span><span>
</span><span id="line-11"></span><span class="hs-comment">-- Maintainer  :  ffi@haskell.org</span><span>
</span><span id="line-12"></span><span class="hs-comment">-- Stability   :  provisional</span><span>
</span><span id="line-13"></span><span class="hs-comment">-- Portability :  portable</span><span>
</span><span id="line-14"></span><span class="hs-comment">--</span><span>
</span><span id="line-15"></span><span class="hs-comment">-- The 'ForeignPtr' type and operations.  This module is part of the</span><span>
</span><span id="line-16"></span><span class="hs-comment">-- Foreign Function Interface (FFI) and will usually be imported via</span><span>
</span><span id="line-17"></span><span class="hs-comment">-- the &quot;Foreign&quot; module.</span><span>
</span><span id="line-18"></span><span class="hs-comment">--</span><span>
</span><span id="line-19"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-20"></span><span>
</span><span id="line-21"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">Foreign.ForeignPtr.Imp</span><span>
</span><span id="line-22"></span><span>        </span><span class="hs-special">(</span><span> </span><span>
</span><span id="line-23"></span><span>        </span><span class="annot"><span class="hs-comment">-- * Finalised data pointers</span></span><span>
</span><span id="line-24"></span><span>          </span><span class="annot"><a href="GHC.ForeignPtr.html#ForeignPtr"><span class="hs-identifier">ForeignPtr</span></a></span><span>
</span><span id="line-25"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.ForeignPtr.html#FinalizerPtr"><span class="hs-identifier">FinalizerPtr</span></a></span><span>
</span><span id="line-26"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.ForeignPtr.html#FinalizerEnvPtr"><span class="hs-identifier">FinalizerEnvPtr</span></a></span><span>
</span><span id="line-27"></span><span>
</span><span id="line-28"></span><span>        </span><span class="annot"><span class="hs-comment">-- ** Basic operations</span></span><span>
</span><span id="line-29"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Foreign.ForeignPtr.Imp.html#newForeignPtr"><span class="hs-identifier">newForeignPtr</span></a></span><span>
</span><span id="line-30"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.ForeignPtr.html#newForeignPtr_"><span class="hs-identifier">newForeignPtr_</span></a></span><span>
</span><span id="line-31"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.ForeignPtr.html#addForeignPtrFinalizer"><span class="hs-identifier">addForeignPtrFinalizer</span></a></span><span>
</span><span id="line-32"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Foreign.ForeignPtr.Imp.html#newForeignPtrEnv"><span class="hs-identifier">newForeignPtrEnv</span></a></span><span>
</span><span id="line-33"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.ForeignPtr.html#addForeignPtrFinalizerEnv"><span class="hs-identifier">addForeignPtrFinalizerEnv</span></a></span><span>
</span><span id="line-34"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.ForeignPtr.html#withForeignPtr"><span class="hs-identifier">withForeignPtr</span></a></span><span>
</span><span id="line-35"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.ForeignPtr.html#finalizeForeignPtr"><span class="hs-identifier">finalizeForeignPtr</span></a></span><span>
</span><span id="line-36"></span><span>
</span><span id="line-37"></span><span>        </span><span class="annot"><span class="hs-comment">-- ** Low-level operations</span></span><span>
</span><span id="line-38"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.ForeignPtr.html#unsafeForeignPtrToPtr"><span class="hs-identifier">unsafeForeignPtrToPtr</span></a></span><span>
</span><span id="line-39"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.ForeignPtr.html#touchForeignPtr"><span class="hs-identifier">touchForeignPtr</span></a></span><span>
</span><span id="line-40"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.ForeignPtr.html#castForeignPtr"><span class="hs-identifier">castForeignPtr</span></a></span><span>
</span><span id="line-41"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.ForeignPtr.html#plusForeignPtr"><span class="hs-identifier">plusForeignPtr</span></a></span><span>
</span><span id="line-42"></span><span>
</span><span id="line-43"></span><span>        </span><span class="annot"><span class="hs-comment">-- ** Allocating managed memory</span></span><span>
</span><span id="line-44"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.ForeignPtr.html#mallocForeignPtr"><span class="hs-identifier">mallocForeignPtr</span></a></span><span>
</span><span id="line-45"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.ForeignPtr.html#mallocForeignPtrBytes"><span class="hs-identifier">mallocForeignPtrBytes</span></a></span><span>
</span><span id="line-46"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Foreign.ForeignPtr.Imp.html#mallocForeignPtrArray"><span class="hs-identifier">mallocForeignPtrArray</span></a></span><span>
</span><span id="line-47"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Foreign.ForeignPtr.Imp.html#mallocForeignPtrArray0"><span class="hs-identifier">mallocForeignPtrArray0</span></a></span><span>
</span><span id="line-48"></span><span>        </span><span class="hs-special">)</span><span> </span><span>
</span><span id="line-49"></span><span>        </span><span class="hs-keyword">where</span><span>
</span><span id="line-50"></span><span>
</span><span id="line-51"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Foreign.Ptr.html"><span class="hs-identifier">Foreign.Ptr</span></a></span><span>
</span><span id="line-52"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Foreign.Storable.html"><span class="hs-identifier">Foreign.Storable</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="Foreign.Storable.html#Storable"><span class="hs-identifier">Storable</span></a></span><span class="hs-special">(</span><span class="annot"><a href="Foreign.Storable.html#sizeOf"><span class="hs-identifier">sizeOf</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-53"></span><span>
</span><span id="line-54"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Base.html"><span class="hs-identifier">GHC.Base</span></a></span><span>
</span><span id="line-55"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Num.html"><span class="hs-identifier">GHC.Num</span></a></span><span>
</span><span id="line-56"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.ForeignPtr.html"><span class="hs-identifier">GHC.ForeignPtr</span></a></span><span>
</span><span id="line-57"></span><span>
</span><span id="line-58"></span><span id="local-6989586621679535048"><span class="annot"><a href="Foreign.ForeignPtr.Imp.html#newForeignPtr"><span class="hs-identifier hs-type">newForeignPtr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.ForeignPtr.html#FinalizerPtr"><span class="hs-identifier hs-type">FinalizerPtr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679535048"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679535048"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.ForeignPtr.html#ForeignPtr"><span class="hs-identifier hs-type">ForeignPtr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679535048"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-59"></span><span class="hs-comment">-- ^Turns a plain memory reference into a foreign pointer, and</span><span>
</span><span id="line-60"></span><span class="hs-comment">-- associates a finalizer with the reference.  The finalizer will be</span><span>
</span><span id="line-61"></span><span class="hs-comment">-- executed after the last reference to the foreign object is dropped.</span><span>
</span><span id="line-62"></span><span class="hs-comment">-- There is no guarantee of promptness, however the finalizer will be</span><span>
</span><span id="line-63"></span><span class="hs-comment">-- executed before the program exits.</span><span>
</span><span id="line-64"></span><span id="newForeignPtr"><span class="annot"><span class="annottext">newForeignPtr :: forall a. FinalizerPtr a -&gt; Ptr a -&gt; IO (ForeignPtr a)
</span><a href="Foreign.ForeignPtr.Imp.html#newForeignPtr"><span class="hs-identifier hs-var hs-var">newForeignPtr</span></a></span></span><span> </span><span id="local-6989586621679535001"><span class="annot"><span class="annottext">FinalizerPtr a
</span><a href="#local-6989586621679535001"><span class="hs-identifier hs-var">finalizer</span></a></span></span><span> </span><span id="local-6989586621679535000"><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679535000"><span class="hs-identifier hs-var">p</span></a></span></span><span>
</span><span id="line-65"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span id="local-6989586621679534999"><span class="annot"><span class="annottext">ForeignPtr a
</span><a href="#local-6989586621679534999"><span class="hs-identifier hs-var">fObj</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Ptr a -&gt; IO (ForeignPtr a)
forall a. Ptr a -&gt; IO (ForeignPtr a)
</span><a href="GHC.ForeignPtr.html#newForeignPtr_"><span class="hs-identifier hs-var">newForeignPtr_</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679535000"><span class="hs-identifier hs-var">p</span></a></span><span>
</span><span id="line-66"></span><span>       </span><span class="annot"><span class="annottext">FinalizerPtr a -&gt; ForeignPtr a -&gt; IO ()
forall a. FinalizerPtr a -&gt; ForeignPtr a -&gt; IO ()
</span><a href="GHC.ForeignPtr.html#addForeignPtrFinalizer"><span class="hs-identifier hs-var">addForeignPtrFinalizer</span></a></span><span> </span><span class="annot"><span class="annottext">FinalizerPtr a
</span><a href="#local-6989586621679535001"><span class="hs-identifier hs-var">finalizer</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr a
</span><a href="#local-6989586621679534999"><span class="hs-identifier hs-var">fObj</span></a></span><span>
</span><span id="line-67"></span><span>       </span><span class="annot"><span class="annottext">ForeignPtr a -&gt; IO (ForeignPtr a)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr a
</span><a href="#local-6989586621679534999"><span class="hs-identifier hs-var">fObj</span></a></span><span>
</span><span id="line-68"></span><span>
</span><span id="line-69"></span><span class="hs-comment">-- | This variant of 'newForeignPtr' adds a finalizer that expects an</span><span>
</span><span id="line-70"></span><span class="hs-comment">-- environment in addition to the finalized pointer.  The environment</span><span>
</span><span id="line-71"></span><span class="hs-comment">-- that will be passed to the finalizer is fixed by the second argument to</span><span>
</span><span id="line-72"></span><span class="hs-comment">-- 'newForeignPtrEnv'.</span><span>
</span><span id="line-73"></span><span id="local-6989586621679535039"><span id="local-6989586621679535040"><span class="annot"><a href="Foreign.ForeignPtr.Imp.html#newForeignPtrEnv"><span class="hs-identifier hs-type">newForeignPtrEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span>
</span><span id="line-74"></span><span>    </span><span class="annot"><a href="GHC.ForeignPtr.html#FinalizerEnvPtr"><span class="hs-identifier hs-type">FinalizerEnvPtr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679535040"><span class="hs-identifier hs-type">env</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679535039"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679535040"><span class="hs-identifier hs-type">env</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679535039"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.ForeignPtr.html#ForeignPtr"><span class="hs-identifier hs-type">ForeignPtr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679535039"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span></span><span>
</span><span id="line-75"></span><span id="newForeignPtrEnv"><span class="annot"><span class="annottext">newForeignPtrEnv :: forall env a.
FinalizerEnvPtr env a -&gt; Ptr env -&gt; Ptr a -&gt; IO (ForeignPtr a)
</span><a href="Foreign.ForeignPtr.Imp.html#newForeignPtrEnv"><span class="hs-identifier hs-var hs-var">newForeignPtrEnv</span></a></span></span><span> </span><span id="local-6989586621679534995"><span class="annot"><span class="annottext">FinalizerEnvPtr env a
</span><a href="#local-6989586621679534995"><span class="hs-identifier hs-var">finalizer</span></a></span></span><span> </span><span id="local-6989586621679534994"><span class="annot"><span class="annottext">Ptr env
</span><a href="#local-6989586621679534994"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621679534993"><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679534993"><span class="hs-identifier hs-var">p</span></a></span></span><span>
</span><span id="line-76"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span id="local-6989586621679534992"><span class="annot"><span class="annottext">ForeignPtr a
</span><a href="#local-6989586621679534992"><span class="hs-identifier hs-var">fObj</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Ptr a -&gt; IO (ForeignPtr a)
forall a. Ptr a -&gt; IO (ForeignPtr a)
</span><a href="GHC.ForeignPtr.html#newForeignPtr_"><span class="hs-identifier hs-var">newForeignPtr_</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr a
</span><a href="#local-6989586621679534993"><span class="hs-identifier hs-var">p</span></a></span><span>
</span><span id="line-77"></span><span>       </span><span class="annot"><span class="annottext">FinalizerEnvPtr env a -&gt; Ptr env -&gt; ForeignPtr a -&gt; IO ()
forall env a.
FinalizerEnvPtr env a -&gt; Ptr env -&gt; ForeignPtr a -&gt; IO ()
</span><a href="GHC.ForeignPtr.html#addForeignPtrFinalizerEnv"><span class="hs-identifier hs-var">addForeignPtrFinalizerEnv</span></a></span><span> </span><span class="annot"><span class="annottext">FinalizerEnvPtr env a
</span><a href="#local-6989586621679534995"><span class="hs-identifier hs-var">finalizer</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr env
</span><a href="#local-6989586621679534994"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr a
</span><a href="#local-6989586621679534992"><span class="hs-identifier hs-var">fObj</span></a></span><span>
</span><span id="line-78"></span><span>       </span><span class="annot"><span class="annottext">ForeignPtr a -&gt; IO (ForeignPtr a)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr a
</span><a href="#local-6989586621679534992"><span class="hs-identifier hs-var">fObj</span></a></span><span>
</span><span id="line-79"></span><span>
</span><span id="line-80"></span><span class="hs-comment">-- | This function is similar to 'Foreign.Marshal.Array.mallocArray',</span><span>
</span><span id="line-81"></span><span class="hs-comment">-- but yields a memory area that has a finalizer attached that releases</span><span>
</span><span id="line-82"></span><span class="hs-comment">-- the memory area.  As with 'mallocForeignPtr', it is not guaranteed that</span><span>
</span><span id="line-83"></span><span class="hs-comment">-- the block of memory was allocated by 'Foreign.Marshal.Alloc.malloc'.</span><span>
</span><span id="line-84"></span><span id="local-6989586621679535033"><span class="annot"><a href="Foreign.ForeignPtr.Imp.html#mallocForeignPtrArray"><span class="hs-identifier hs-type">mallocForeignPtrArray</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Foreign.Storable.html#Storable"><span class="hs-identifier hs-type">Storable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679535033"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.ForeignPtr.html#ForeignPtr"><span class="hs-identifier hs-type">ForeignPtr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679535033"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-85"></span><span id="mallocForeignPtrArray"><span class="annot"><span class="annottext">mallocForeignPtrArray :: forall a. Storable a =&gt; Int -&gt; IO (ForeignPtr a)
</span><a href="Foreign.ForeignPtr.Imp.html#mallocForeignPtrArray"><span class="hs-identifier hs-var hs-var">mallocForeignPtrArray</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">a -&gt; Int -&gt; IO (ForeignPtr a)
forall b. Storable b =&gt; b -&gt; Int -&gt; IO (ForeignPtr b)
</span><a href="#local-6989586621679534987"><span class="hs-identifier hs-var">doMalloc</span></a></span><span> </span><span class="annot"><span class="annottext">a
forall a. HasCallStack =&gt; a
</span><a href="GHC.Err.html#undefined"><span class="hs-identifier hs-var">undefined</span></a></span><span>
</span><span id="line-86"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-87"></span><span>    </span><span id="local-6989586621679535029"><span class="annot"><a href="#local-6989586621679534987"><span class="hs-identifier hs-type">doMalloc</span></a></span><span>            </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Foreign.Storable.html#Storable"><span class="hs-identifier hs-type">Storable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679535029"><span class="hs-identifier hs-type">b</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679535029"><span class="hs-identifier hs-type">b</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.ForeignPtr.html#ForeignPtr"><span class="hs-identifier hs-type">ForeignPtr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679535029"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-88"></span><span>    </span><span id="local-6989586621679534987"><span class="annot"><span class="annottext">doMalloc :: forall b. Storable b =&gt; b -&gt; Int -&gt; IO (ForeignPtr b)
</span><a href="#local-6989586621679534987"><span class="hs-identifier hs-var hs-var">doMalloc</span></a></span></span><span> </span><span id="local-6989586621679534981"><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621679534981"><span class="hs-identifier hs-var">dummy</span></a></span></span><span> </span><span id="local-6989586621679534980"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679534980"><span class="hs-identifier hs-var">size</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; IO (ForeignPtr b)
forall a. Int -&gt; IO (ForeignPtr a)
</span><a href="GHC.ForeignPtr.html#mallocForeignPtrBytes"><span class="hs-identifier hs-var">mallocForeignPtrBytes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679534980"><span class="hs-identifier hs-var">size</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="GHC.Num.html#%2A"><span class="hs-operator hs-var">*</span></a></span><span> </span><span class="annot"><span class="annottext">b -&gt; Int
forall a. Storable a =&gt; a -&gt; Int
</span><a href="Foreign.Storable.html#sizeOf"><span class="hs-identifier hs-var">sizeOf</span></a></span><span> </span><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621679534981"><span class="hs-identifier hs-var">dummy</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-89"></span><span>
</span><span id="line-90"></span><span class="hs-comment">-- | This function is similar to 'Foreign.Marshal.Array.mallocArray0',</span><span>
</span><span id="line-91"></span><span class="hs-comment">-- but yields a memory area that has a finalizer attached that releases</span><span>
</span><span id="line-92"></span><span class="hs-comment">-- the memory area.  As with 'mallocForeignPtr', it is not guaranteed that</span><span>
</span><span id="line-93"></span><span class="hs-comment">-- the block of memory was allocated by 'Foreign.Marshal.Alloc.malloc'.</span><span>
</span><span id="line-94"></span><span id="local-6989586621679534978"><span class="annot"><a href="Foreign.ForeignPtr.Imp.html#mallocForeignPtrArray0"><span class="hs-identifier hs-type">mallocForeignPtrArray0</span></a></span><span>      </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Foreign.Storable.html#Storable"><span class="hs-identifier hs-type">Storable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679534978"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.ForeignPtr.html#ForeignPtr"><span class="hs-identifier hs-type">ForeignPtr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679534978"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-95"></span><span id="mallocForeignPtrArray0"><span class="annot"><span class="annottext">mallocForeignPtrArray0 :: forall a. Storable a =&gt; Int -&gt; IO (ForeignPtr a)
</span><a href="Foreign.ForeignPtr.Imp.html#mallocForeignPtrArray0"><span class="hs-identifier hs-var hs-var">mallocForeignPtrArray0</span></a></span></span><span> </span><span id="local-6989586621679534973"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679534973"><span class="hs-identifier hs-var">size</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; IO (ForeignPtr a)
forall a. Storable a =&gt; Int -&gt; IO (ForeignPtr a)
</span><a href="Foreign.ForeignPtr.Imp.html#mallocForeignPtrArray"><span class="hs-identifier hs-var">mallocForeignPtrArray</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679534973"><span class="hs-identifier hs-var">size</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span>
</span><span id="line-96"></span><span>
</span><span id="line-97"></span></pre></body></html>